

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>mindspore.nn.probability.distribution.TransformedDistribution &mdash; MindSpore master documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="mindspore.nn.probability.distribution.Uniform" href="mindspore.nn.probability.distribution.Uniform.html" />
    <link rel="prev" title="mindspore.nn.probability.distribution.Poisson" href="mindspore.nn.probability.distribution.Poisson.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> MindSpore
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">MindSpore Python API</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../mindspore.html">mindspore</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.common.initializer.html">mindspore.common.initializer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.communication.html">mindspore.communication</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.compression.html">mindspore.compression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.context.html">mindspore.context</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.html">mindspore.dataset</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.audio.html">mindspore.dataset.audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.config.html">mindspore.dataset.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.text.html">mindspore.dataset.text</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.transforms.html">mindspore.dataset.transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.vision.html">mindspore.dataset.vision</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.mindrecord.html">mindspore.mindrecord</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.html">mindspore.nn</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../mindspore.nn.probability.html">mindspore.nn.probability</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../mindspore.nn.probability.html#bijectors">Bijectors</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../mindspore.nn.probability.html#distributions">Distributions</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Bernoulli.html">mindspore.nn.probability.distribution.Bernoulli</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Beta.html">mindspore.nn.probability.distribution.Beta</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Categorical.html">mindspore.nn.probability.distribution.Categorical</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Cauchy.html">mindspore.nn.probability.distribution.Cauchy</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Distribution.html">mindspore.nn.probability.distribution.Distribution</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Exponential.html">mindspore.nn.probability.distribution.Exponential</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Gamma.html">mindspore.nn.probability.distribution.Gamma</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Geometric.html">mindspore.nn.probability.distribution.Geometric</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Gumbel.html">mindspore.nn.probability.distribution.Gumbel</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Logistic.html">mindspore.nn.probability.distribution.Logistic</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.LogNormal.html">mindspore.nn.probability.distribution.LogNormal</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Normal.html">mindspore.nn.probability.distribution.Normal</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Poisson.html">mindspore.nn.probability.distribution.Poisson</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">mindspore.nn.probability.distribution.TransformedDistribution</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.nn.probability.distribution.Uniform.html">mindspore.nn.probability.distribution.Uniform</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.transformer.html">mindspore.nn.transformer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.numpy.html">mindspore.numpy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.ops.html">mindspore.ops</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.html">mindspore.parallel</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.nn.html">mindspore.parallel.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.profiler.html">mindspore.profiler</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.scipy.html">mindspore.scipy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.train.html">mindspore.train</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.boost.html">mindspore.boost</a></li>
</ul>
<p class="caption"><span class="caption-text">MindSpore C++ API</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://www.mindspore.cn/lite/api/zh-CN/master/api_cpp/mindspore.html">MindSpore Lite↗</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">MindSpore</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../mindspore.nn.probability.html">mindspore.nn.probability</a> &raquo;</li>
        
      <li>mindspore.nn.probability.distribution.TransformedDistribution</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/api_python/nn_probability/mindspore.nn.probability.distribution.TransformedDistribution.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="mindspore-nn-probability-distribution-transformeddistribution">
<h1>mindspore.nn.probability.distribution.TransformedDistribution<a class="headerlink" href="#mindspore-nn-probability-distribution-transformeddistribution" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="mindspore.nn.probability.distribution.TransformedDistribution">
<em class="property">class </em><code class="sig-prename descclassname">mindspore.nn.probability.distribution.</code><code class="sig-name descname">TransformedDistribution</code><span class="sig-paren">(</span><em class="sig-param">bijector</em>, <em class="sig-param">distribution</em>, <em class="sig-param">seed=None</em>, <em class="sig-param">name='transformed_distribution'</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.nn.probability.distribution.TransformedDistribution" title="Permalink to this definition">¶</a></dt>
<dd><p>转换分布（Transformed Distribution）。
该类包含一个Bijector和一个分布，并通过Bijector定义的操作将原始分布转换为新分布。可如果原始分布为 <span class="math notranslate nohighlight">\(X\)</span> ，Bijector的映射函数为 <span class="math notranslate nohighlight">\(g\)</span>， 那么对应的转换分布为 <span class="math notranslate nohighlight">\(Y = g(X)\)</span> 。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>bijector</strong> (Bijector) - 要执行的转换。</p></li>
<li><p><strong>distribution</strong> (Distribution) - 原始分布。必须具有float数据类型。</p></li>
<li><p><strong>seed</strong> (int) - 采样时使用的种子。如果为None，则使用全局种子。默认值：None。如果在初始化TransformedDistribution对象时给出了此种子，则对象的采样函数将使用此种子；否则，将使用基础分布的种子。</p></li>
<li><p><strong>name</strong> (str) - 转换分布的名称。默认值：’transformed_distribution’。</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>用于初始化原始分布的参数不能为None。例如，由于未指定 <cite>mean</cite> 和 <cite>sd</cite> ，因此无法使用mynormal = msd.Normal(dtype=mindspore.float32)初始化TransformedDistribution。</p>
</div>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>TypeError</strong> - bijector不是Bijector类。</p></li>
<li><p><strong>TypeError</strong> - distribution不是Distribution类。</p></li>
</ul>
<p><strong>支持平台：</strong></p>
<p><code class="docutils literal notranslate"><span class="pre">Ascend</span></code> <code class="docutils literal notranslate"><span class="pre">GPU</span></code></p>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mindspore</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mindspore.nn</span> <span class="k">as</span> <span class="nn">nn</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mindspore.nn.probability.distribution</span> <span class="k">as</span> <span class="nn">msd</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mindspore.nn.probability.bijector</span> <span class="k">as</span> <span class="nn">msb</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">mindspore</span> <span class="kn">import</span> <span class="n">Tensor</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">Net</span><span class="p">(</span><span class="n">nn</span><span class="o">.</span><span class="n">Cell</span><span class="p">):</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">shape</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">mindspore</span><span class="o">.</span><span class="n">float32</span><span class="p">,</span> <span class="n">seed</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;transformed_distribution&#39;</span><span class="p">):</span>
<span class="gp">... </span>        <span class="nb">super</span><span class="p">(</span><span class="n">Net</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
<span class="gp">... </span>        <span class="c1"># create TransformedDistribution distribution</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">exp</span> <span class="o">=</span> <span class="n">msb</span><span class="o">.</span><span class="n">Exp</span><span class="p">()</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">normal</span> <span class="o">=</span> <span class="n">msd</span><span class="o">.</span><span class="n">Normal</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">dtype</span><span class="p">)</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">lognormal</span> <span class="o">=</span> <span class="n">msd</span><span class="o">.</span><span class="n">TransformedDistribution</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">exp</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">normal</span><span class="p">,</span> <span class="n">seed</span><span class="o">=</span><span class="n">seed</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">)</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">shape</span> <span class="o">=</span> <span class="n">shape</span>
<span class="gp">...</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="nf">construct</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="gp">... </span>        <span class="n">cdf</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lognormal</span><span class="o">.</span><span class="n">cdf</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="gp">... </span>        <span class="n">sample</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lognormal</span><span class="o">.</span><span class="n">sample</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
<span class="gp">... </span>        <span class="k">return</span> <span class="n">cdf</span><span class="p">,</span> <span class="n">sample</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">shape</span> <span class="o">=</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">net</span> <span class="o">=</span> <span class="n">Net</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="n">shape</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;LogNormal&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">2.0</span><span class="p">,</span> <span class="mf">3.0</span><span class="p">,</span> <span class="mf">4.0</span><span class="p">,</span> <span class="mf">5.0</span><span class="p">])</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">tx</span> <span class="o">=</span> <span class="n">Tensor</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">mindspore</span><span class="o">.</span><span class="n">float32</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">cdf</span><span class="p">,</span> <span class="n">sample</span> <span class="o">=</span> <span class="n">net</span><span class="p">(</span><span class="n">tx</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">sample</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
<span class="go">(2, 3)</span>
</pre></div>
</div>
<dl class="method">
<dt id="mindspore.nn.probability.distribution.TransformedDistribution.bijector">
<em class="property">property </em><code class="sig-name descname">bijector</code><a class="headerlink" href="#mindspore.nn.probability.distribution.TransformedDistribution.bijector" title="Permalink to this definition">¶</a></dt>
<dd><p>返回概率映射函数。</p>
<p><strong>返回：</strong></p>
<p>Bijector, 概率映射函数。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.nn.probability.distribution.TransformedDistribution.distribution">
<em class="property">property </em><code class="sig-name descname">distribution</code><a class="headerlink" href="#mindspore.nn.probability.distribution.TransformedDistribution.distribution" title="Permalink to this definition">¶</a></dt>
<dd><p>返回变化前的概率分布。</p>
<p><strong>返回：</strong></p>
<p>Distribution, 变化前的概率分布。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.nn.probability.distribution.TransformedDistribution.is_linear_transformation">
<em class="property">property </em><code class="sig-name descname">is_linear_transformation</code><a class="headerlink" href="#mindspore.nn.probability.distribution.TransformedDistribution.is_linear_transformation" title="Permalink to this definition">¶</a></dt>
<dd><p>返回概率映射函数是否为线性映射。</p>
<p><strong>返回：</strong></p>
<p>Bool, 概率映射函数为线性映射则返回True，否则返回False。</p>
</dd></dl>

</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="mindspore.nn.probability.distribution.Uniform.html" class="btn btn-neutral float-right" title="mindspore.nn.probability.distribution.Uniform" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="mindspore.nn.probability.distribution.Poisson.html" class="btn btn-neutral float-left" title="mindspore.nn.probability.distribution.Poisson" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2021, MindSpore.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>